@include('home.public.header')
<!-- HEADING-BANNER START -->
<div class="heading-banner-area overlay-bg">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="heading-banner">
                    <div class="heading-banner-title">
                        <h2>Shop</h2>
                    </div>
                    <div class="breadcumbs pb-15">
                        <ul>
                            <li><a href="/">Home</a></li>
                            <li>Shop</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- HEADING-BANNER END -->
<!-- PRODUCT-AREA START -->
<div class="product-area pt-80 pb-80 product-style-2 bg-dark-white">
    <div class="container">
        <!-- Shop-Content End -->
        <div class="shop-content">
            <div class="row ">
                <div class="col-md-12">
                    <div class="product-option mb-30 clearfix">
                        <!-- Categories start -->
                        <div class="dropdown floatleft">
                            <button class="option-btn cat-menu " >
                                分类
                            </button>
                            <div class="dropdown-menu dropdown-width " >
                                <!-- Widget-Categories start -->
                                <aside class="widget widget-categories">
                                    <div class="widget-title">
                                        <h4>类别</h4>
                                    </div>
                                    <div id="cat-treeview"  class="widget-info product-cat boxscrol2">
                                        <ul class="classify">
                                            {{--内容--}}
                                        </ul>
                                    </div>
                                </aside>
                                <!-- Widget-categories end -->
                            </div>
                        </div>
                        <!-- Categories end -->
                        <!-- Price start -->
                        <div class="dropdown floatleft">
                            <button class="option-btn " >
                                价格
                            </button>
                            <div class="dropdown-menu dropdown-width" >
                                <!-- Shop-Filter start -->
                                <aside class="widget shop-filter">
                                    <div class="widget-title">
                                        <h4>价格</h4>
                                    </div>
                                    <div class="widget-info">
                                        <div class="price_filter">
                                            <div class="price_slider_amount">
                                                <input type="submit"  value="You range :"/>
                                                <input type="text" id="amount" name="price"  placeholder="Add Your Price" />
                                            </div>
                                            <div id="slider-range"></div>
                                        </div>
                                    </div>
                                </aside>
                                <!-- Shop-Filter end -->
                            </div>
                        </div>
                        <!-- Price end -->
                        <!-- Color start -->
                        <div class="dropdown floatleft">
                            <button class="option-btn color">
                                颜色
                            </button>
                            <div class="dropdown-menu dropdown-width" >
                                <!-- Widget-Color start -->
                                <aside class="widget widget-color">
                                    <div class="widget-title">
                                        <h4>颜色</h4>
                                    </div>
                                    <div class="widget-info color-filter clearfix">
                                        <ul class="color_list clearfix">
{{--                                            <li><a href="#"><span class="color color-1"></span>LightSalmon<span class="count">12</span></a></li>--}}
{{--                                            <li><a href="#"><span class="color color-2"></span>Dark Salmon<span class="count">20</span></a></li>--}}
{{--                                            <li><a href="#"><span class="color color-3"></span>Tomato<span class="count">59</span></a></li>--}}
{{--                                            <li class="active"><a href="#"><span class="color color-4"></span>Deep Sky Blue<span class="count">45</span></a></li>--}}
{{--                                            <li><a href="#"><span class="color color-5"></span>Electric Purple<span class="count">78</span></a></li>--}}
{{--                                            <li><a href="#"><span class="color color-6"></span>Atlantis<span class="count">10</span></a></li>--}}
{{--                                            <li><a href="#"><span class="color color-7"></span>Deep Lilac<span class="count">15</span></a></li>--}}
                                        </ul>
                                    </div>
                                </aside>
                                <!-- Widget-Color end -->
                            </div>
                        </div>
                        <!-- Color end -->
                        <!-- Size start -->
                        <div class="dropdown floatleft">
                            <button class="option-btn size">
                                尺寸
                            </button>
                            <div class="dropdown-menu dropdown-width" >
                                <!-- Widget-Size start -->
                                <aside class="widget widget-size">
                                    <div class="widget-title">
                                        <h4>尺寸</h4>
                                    </div>
                                    <div class="widget-info size-filter clearfix">
                                        <ul class="size_list">
                                            <li><a href="javascript:;">M</a></li>
                                            <li class="active"><a href="javascript:;">S</a></li>
                                            <li><a href="javascript:;">L</a></li>
                                            <li><a href="javascript:;">SL</a></li>
                                            <li><a href="javascript:;">XL</a></li>
                                        </ul>
                                    </div>
                                </aside>
                                <!-- Widget-Size end -->
                            </div>
                        </div>
                        <!-- Size end -->
                        <div class="showing text-right">
                            <p class="mb-0 hidden-xs">Showing 01-09 of 17 Results</p>
                        </div>
                    </div>
                </div>
                <div class="col-md-12">
                    <div class="row">
                        <!-- Single-product start -->
                        <div id="row_list">
                            {{--内容--}}
                        </div>

                        <!-- Single-product end -->
                    </div>
                </div>
{{--                <div class="col-md-12">--}}
{{--                    <!-- Pagination start -->--}}
{{--                    <div class="shop-pagination  text-center">--}}
{{--                        <div class="pagination">--}}
{{--                            <ul>--}}
{{--                                <li><a href="#"><i class="zmdi zmdi-long-arrow-left"></i></a></li>--}}
{{--                                <li><a href="#">01</a></li>--}}
{{--                                <li class="active"><a href="#">02</a></li>--}}
{{--                                <li><a href="#">03</a></li>--}}
{{--                                <li><a href="#">04</a></li>--}}
{{--                                <li><a href="#">05</a></li>--}}
{{--                                <li><a href="#"><i class="zmdi zmdi-long-arrow-right"></i></a></li>--}}
{{--                            </ul>--}}
{{--                        </div>--}}
{{--                    </div>--}}
{{--                    <!-- Pagination end -->--}}
{{--                </div>--}}
            </div>
        </div>
        <!-- Shop-Content End -->
    </div>
</div>
<!-- PRODUCT-AREA END -->
@include('home.public.footer2')
<script>
    //搜索
    var classify_id = '';
    var page = '';
    var color_name = '';
    var good_size = '';
    var good_price = '';
    var goodid = '';
    //处理参数
    function getArguments() {
        var getArgument = '';
        if(classify_id != '') {
            getArgument += '&classify_id='+classify_id;
        }
        if(color_name != '') {
            getArgument += '&color_name='+color_name;
        }
        if(good_size != '') {
            getArgument += '&good_size='+good_size;
        }
        if(good_price != '') {
            getArgument += '&good_price='+good_price;
        }
        return getArgument;
    }
    //点击分类查询
    $(document).on('click','.classify li span',function () {
        classify_id =  $(this).attr('classify');
        page = $('#cur').html();
        $.ajax({
            type: 'get',
            url: '/shop_list',
            data: "page=1"+"&classify_id="+classify_id,
            dataType: "html",
            success:function(res){
                // console.log(res)
                $("#row_list").html(res);

            }
        });
    });

    //点击颜色查询
    $(document).on('click','.color_list li',function () {
        color_name = $(this).children().eq(1).html();
        $.ajax({
            type: 'get',
            url: '/shop_list',
            data: "page=1"+"&color_name="+color_name,
            dataType: "html",
            success:function(res){
                // console.log(res)
                $("#row_list").html(res);

            }
        });
    });

    //尺寸查询
    $(document).on('click','.size_list li',function () {
        good_size = $(this).children().html()
        $(this).addClass('active').siblings().removeClass();
        page = $('#cur').html();
        $.ajax({
            type: 'get',
            url: '/shop_list',
            data: "page=1"+"&good_size="+good_size,
            dataType: "html",
            success:function(res){
                // console.log(res)
                $("#row_list").html(res);

            }
        });
    });

    // 价格查询
    $(document).on('mouseup','.ui-slider-handle',function () {
        good_price = $('#amount').val();
        // console.log(good_price);
        good_price = good_price.replace(/\$+/g,'');
        // console.log(good_price);
        page = $('#cur').html();
        $.ajax({
            type: 'get',
            url: '/shop_list',
            data: "page=1"+"&good_price="+good_price,
            dataType: "html",
            success:function(res){
                // console.log(res)
                $("#row_list").html(res);

            }
        });
    })

    //分类
    $(document).on('click','.cat-menu',function () {
        $.ajax({
            type: 'get',
            url: '/get_classify',
            data: "",
            dataType: "html",
            success:function(res){
                $(".classify").html(res);
            }
        });
        return false;
    });

    // 颜色
    $(document).on('click','.color',function () {
        $.ajax({
            type: 'get',
            url: '/get_color',
            data: "",
            dataType: "html",
            success:function(res){
                // console.log(res)
                $(".color_list").html(res);
            }
        });
        return false;
    });

    //弹框下单
    $(document).on('click',"#modal",function () {
        goodid =  $(this).attr('goodid');
        $.ajax({
            type: 'get',
            url: '/goodid',
            data: "goodid="+goodid,
            dataType: "html",
            success:function(res){
                console.log(res);
                // $("#row_list").html(res);
            }
        })
    });

    //心愿单
    $(document).on('click',"#wish",function () {
        goodid =  $(this).attr('goodid');
        var falg = $(this).attr('class');
        let that = this;
        if(falg == 1) {
            // console.log(1)
            $.ajax({
                type: 'post',
                url: '/wish',
                data: {'goodid':goodid},
                dataType: "html",
                success:function(res){
                    if(res==1) {
                        // console.log($('#wish .zmdi '))
                        $(that).addClass('wishColor');
                    }
                }
            })
        } else {
            // console.log(2)
            //取消心愿单
            $.ajax({
                type: 'post',
                url: '/wish_del',
                data: {'goodid':goodid},
                dataType: "html",
                success:function(res){
                    if(res==1) {
                        // console.log($('#wish .zmdi '))
                        $(that).removeClass('wishColor');
                       var falg = 1;
                    }
                }
            })
        }
    });

    //购物车
    $(document).on('click',"#cart",function () {
        goodid =  $(this).attr('goodid');
        var falg = $(this).attr('class');
        let that = this;
        if(falg == 1) {
            // console.log(1)
            $.ajax({
                type: 'post',
                url: '/cart',
                data: {'goodid':goodid},
                dataType: "html",
                success:function(res){
                    if(res==1) {
                        // console.log($('#wish .zmdi '))
                        $(that).addClass('cartColor');
                    }
                }
            })
        } else {
            // console.log(2)
            //取消心愿单
            $.ajax({
                type: 'post',
                url: '/cart_del',
                data: {'goodid':goodid},
                dataType: "html",
                success:function(res){
                    if(res==1) {
                        // console.log($('#wish .zmdi '))
                        $(that).removeClass('cartColor');
                        var falg = 1;
                    }
                }
            })
        }
    });





    //阻止a默认跳转
    $(document).on('click',".num a",function () {

        //点击页码请求接口
        var page = $(this).html();
        var data =  getArguments();
        getList(page,data);
        return false;
    });

    //点击上一页请求接口
    $(document).on("click","#preva",function () {
        var cur = $("#cur").html();
        var page = parseInt(cur) - 1 ;
        var data =  getArguments();
        getList(page,data);

        return false;
    });

    //点击下一页请求接口
    $(document).on("click","#nexta",function () {
        var cur = $("#cur").html();
        var page = parseInt(cur) + 1;
        var data =  getArguments();
        getList(page,data);
        return false;
    });

    function getList(page,getsearch=''){
        $.ajax({
            type: 'get',
            url: '/shop_list',
            data: "page="+page+'&'+getsearch,
            dataType: "html",
            success:function(res){
                // console.log(res);
                $("#row_list").html(res);
            }
        })
    }

    getList(1);
</script>

